<?php

session_start();

include_once( 'config.php' );
include_once( 'saet.ex.class.php' );

if( isset($_SESSION['last_key']) )
{

    $c = new SaeTClient( WB_AKEY , WB_SKEY , $_SESSION['last_key']['oauth_token'] , $_SESSION['last_key']['oauth_token_secret']  );
    $ms  = $c->home_timeline(); // done

} else {

    $o = new SaeTOAuth( WB_AKEY , WB_SKEY  );

    $keys = $o->getRequestToken();
    $aurl = $o->getAuthorizeURL( $keys['oauth_token'] ,false , 'http://' . $_SERVER['HTTP_APPNAME'] . '.sinaapp.com/t/callback.php');

    $_SESSION['keys'] = $keys;

    header("Location: " . $aurl);
}

?>
<!doctype html>
<html manifest="manifest.cache"> 
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">	
    <title>Gossips</title>
    
    <link rel="stylesheet" href="resources/css/application.css" type="text/css">
</head>
<body>
    <!-- 
        This is your development file. This should load the debug versions of third party library, and load
        your application file by file (the Sencha Command generators help automate this). See deploy/index.html
        for the production version of this file
     -->
     
    <script type="text/javascript" src="../sencha-touch.js"></script>
    <script type="text/javascript" src="lib/GossipsProxy.js"></script>
    
    <div id="sencha-app">
        <script type="text/javascript" src="app/routes.js"></script>
        <script type="text/javascript" src="app/app.js"></script>
        
        <!-- Place your view files here -->
        <div id="sencha-views">
            <script type="text/javascript" src="app/views/Viewport.js"></script>
            
            <script type="text/javascript" src="app/views/Searches.js"></script>
            <script type="text/javascript" src="app/views/SearchBar.js"></script>
            <script type="text/javascript" src="app/views/Tweets.js"></script>
        </div>
        
        <!-- Place your model files here -->
        <div id="sencha-models">
            <script type="text/javascript" src="app/models/Search.js"></script>
            <script type="text/javascript" src="app/models/Tweet.js"></script>
            
        </div>
        
        <!-- Place your controller files here -->
        <div id="sencha-controllers">
            <script type="text/javascript" src="app/controllers/searches.js"></script>
            
        </div>
        
        <!-- Place your store files here -->
        <div id="sencha-controllers">
            <script type="text/javascript" src="app/stores/Searches.js"></script>
            
        </div>
    </div>
</body>
</html>
